using Serilog;
using Worldme.YHChatSDK.Framework.Core;
using Worldme.YHChatSDK.Framework.Vo;

namespace Worldme.YHChatSDK
{
    public static class YHChatSDKApplication
    {
        private static string _token;
        public static void Initializate(string token)
        {
            _token = token;
            InitializeLogger();
            InitializePluginManager();
        }

        public static string GetToken()
        {
            return _token;
        }

        internal static void InitializeLogger()
        {
            Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Debug()
                .WriteTo.Console()
                .CreateLogger();
        }

        internal static void InitializePluginManager()
        {
            Log.Information("【YHChatSDK】加载插件开始...");
            int allNum = 0;
            GlobalPluginHandel globalData = GlobalPluginHandel.GetInstance();

            //普通消息事件插件
            List<PluginManagerVo.EventMessageReceiveNormalVo> loadList1 = PluginLoadHandler.LoadEventMessageReceiveNormal();
            List<PluginManagerVo.EventMessageReceiveNormalVo> dataList1 = globalData.GetEventMessageReceiveNormalVos();
            dataList1.AddRange(loadList1);
            allNum = allNum + loadList1.Count();
            Log.Information("【YHChatSDK】加载[普通消息事件]插件完成，共{count}个", loadList1.Count());

            //指令消息事件插件
            List<PluginManagerVo.EventMessageReceiveInstructionVo> loadList2 = PluginLoadHandler.LoadEventMessageReceiveInstruction();
            List<PluginManagerVo.EventMessageReceiveInstructionVo> dataList2 = globalData.GetEventMessageReceiveInstructionVos();
            dataList2.AddRange(loadList2);
            allNum = allNum + loadList2.Count();
            Log.Information("【YHChatSDK】加载[指令消息事件]插件完成，共{count}个", loadList2.Count());

            //关注机器人事件
            List<PluginManagerVo.EventBotFollowedVo> loadList3 = PluginLoadHandler.LoadEventBotFollowed();
            List<PluginManagerVo.EventBotFollowedVo> dataList3 = globalData.GetEventBotFollowedVos();
            dataList3.AddRange(loadList3);
            allNum = allNum + loadList3.Count();
            Log.Information("【YHChatSDK】加载[关注机器人事件]插件完成，共{count}个", loadList3.Count());

            //取消关注机器人事件
            List<PluginManagerVo.EventBotUnfollowedVo> loadList4 = PluginLoadHandler.LoadEventBotUnfollowed();
            List<PluginManagerVo.EventBotUnfollowedVo> dataList4 = globalData.GetEventBotUnfollowedVos();
            dataList4.AddRange(loadList4);
            allNum = allNum + loadList4.Count();
            Log.Information("【YHChatSDK】加载[取消关注机器人事件]插件完成，共{count}个", loadList4.Count());

            //消息中按钮点击事件
            List<PluginManagerVo.EventButtonReportInlineVo> loadList5 = PluginLoadHandler.LoadEventButtonReportInline();
            List<PluginManagerVo.EventButtonReportInlineVo> dataList5 = globalData.GetEventButtonReportInlineVos();
            dataList5.AddRange(loadList5);
            allNum = allNum + loadList5.Count();
            Log.Information("【YHChatSDK】加载[消息中按钮点击事件]插件完成，共{count}个", loadList5.Count());

            //加入群事件
            List<PluginManagerVo.EventGroupJoinVo> loadList6 = PluginLoadHandler.LoadEventGroupJoin();
            List<PluginManagerVo.EventGroupJoinVo> dataList6 = globalData.GetEventGroupJoinVos();
            dataList6.AddRange(loadList6);
            allNum = allNum + loadList6.Count();
            Log.Information("【YHChatSDK】加载[用户加入群事件]插件完成，共{count}个", loadList6.Count());

            //退出群事件
            List<PluginManagerVo.EventGroupLeaveVo> loadList7 = PluginLoadHandler.LoadEventGroupLeave();
            List<PluginManagerVo.EventGroupLeaveVo> dataList7 = globalData.GetEventGroupLeaveVos();
            dataList7.AddRange(loadList7);
            allNum = allNum + loadList7.Count();
            Log.Information("【YHChatSDK】加载[用户退出群事件]插件完成，共{count}个", loadList7.Count());

            //机器人设置事件
            List<PluginManagerVo.EventBotShutcutMenuVo> loadList8 = PluginLoadHandler.LoadEventBotShutcutMenu();
            List<PluginManagerVo.EventBotShutcutMenuVo> dataList8 = globalData.GetEventBotShutcutMenuVos();
            dataList8.AddRange(loadList8);
            allNum = allNum + loadList8.Count();
            Log.Information("【YHChatSDK】加载[聊天框上方菜单按钮事件]插件完成，共{count}个", loadList8.Count());

            Log.Information("【YHChatSDK】加载插件结束，共{allNum}个", allNum);
            Log.Information("【YHChatSDK】核心启动完成，欢迎使用");


            Log.Information("\n\n" +
                " _     _  _   _  ___    _             _       _   _         _    ___                      \r\n" +
                "( )   ( )( ) ( )(  _`\\ ( )           ( )_    ( ) ( )       ( )_ (  _`\\                    \r\n" +
                "`\\`\\_/'/'| |_| || ( (_)| |__     _ _ | ,_)   | `\\| |   __  | ,_)| ( (_)   _    _ __   __  \r\n" +
                "  `\\ /'  |  _  || |  _ |  _ `\\ /'_` )| |     | , ` | /'__`\\| |  | |  _  /'_`\\ ( '__)/'__`\\\r\n" +
                "   | |   | | | || (_( )| | | |( (_| || |_    | |`\\ |(  ___/| |_ | (_( )( (_) )| |  (  ___/\r\n" +
                "   (_)   (_) (_)(____/'(_) (_)`\\__,_)`\\__)   (_) (_)`\\____)`\\__)(____/'`\\___/'(_)  `\\____)\r\n" +
                "                                                                                          \r\n" +
                "                                                                                          \r\n" +
                " ___    _     _     _       _              _        _                    _____  ___       \r\n" +
                "(  _`\\ ( )   ( )   ( )  _  ( )            (_ )     ( )                  (  _  )(  _`\\     \r\n" +
                "| (_) )`\\`\\_/'/'   | | ( ) | |   _    _ __ | |    _| |  ___ ___     __  | ( ) || ( (_)    \r\n" +
                "|  _ <'  `\\ /'     | | | | | | /'_`\\ ( '__)| |  /'_` |/' _ ` _ `\\ /'__`\\| | | || |  _     \r\n" +
                "| (_) )   | |      | (_/ \\_) |( (_) )| |   | | ( (_| || ( ) ( ) |(  ___/| (('\\|| (_( )    \r\n" +
                "(____/'   (_)      `\\___x___/'`\\___/'(_)  (___)`\\__,_)(_) (_) (_)`\\____)(___\\_)(____/'    \r\n" +
                "                                                                                          \r\n" +
                "                                                                                          \r\n");
        }



    }
}
